# -*- coding: utf-8 -*-
"""
Created on Thu Apr 05 12:29:06 2012

@author: Daniel
"""
import numpy as np
from matplotlib import pylab
from scipy import optimize
def fcn(x):
    return x**2 + 10*np.sin(x)

x = np.arange(-10,10,0.1)
#matplotlib.pylab.plot
pylab.plot(x, fcn(x)) 
pylab.show() 
xMin=optimize.fmin_bfgs(fcn, 10)
pylab.plot([xMin], [fcn(xMin)],'ro')
pylab.show()
def func(x, sign=1.0):
    """ Objective function """
    return sign*(2*x[0]*x[1] + 2*x[0] - x[0]**2 - 2*x[1]**2)
def con1_EQ(x,params=1.0):
    return np.array(x[0]**3-x[1])
def con2_IQ(x,params=1.0):
    return np.array(x[1]-1)
    
x0=[1,1]
funcPrime=None
funcPrimeCons=None
eqCons=[]
bounds=[]
args=()
tol=1e-5
Niter=100
epsilon=1.5e-8
#optimize.slsqp(func,x0,eqCons,con1_EQ,bounds,funcPrime,funcPrimeCons,args,Niter,tol,1,1,epsilon)
#fmin_slsqp( func, x0 , eqcons=[], f_eqcons=None, ieqcons=[], f_ieqcons=None,
#                bounds = [], fprime = None, fprime_cons=None,args = (), 
#                iter = 100, acc = 1.0E-6, iprint = 1, full_output = 0, 
#                epsilon = _epsilon ):
